package com.hm.search.config;

import com.hm.search.cnstants.MqConstants;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MqConfig {
    @Bean
    public TopicExchange topicExchange(){
        return new TopicExchange(MqConstants.HM_EXCHANGE);
    }

    @Bean
    public Queue InsertQueue(){
        return new Queue(MqConstants.HM_INSERT_QUEUE);
    }

    @Bean
    public Queue DeleteQueue(){
        return new Queue(MqConstants.HM_DELETE_QUEUE);
    }




    @Bean
    public Binding InsertBinding(){
        return BindingBuilder.bind(InsertQueue()).to(topicExchange())
                .with(MqConstants.HM_INSERT_KEY);
    }



    @Bean
    public Binding DeleteBinding(){
        return BindingBuilder.bind(DeleteQueue()).to(topicExchange())
                .with(MqConstants.HM_DELETE_KEY);
    }
}
